package Utils;

import org.apache.commons.beanutils.Converter;
import sun.plugin2.message.Conversation;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConvertor implements Converter {
	private String pattern;

	public DateConvertor(String pattern) {
		this.pattern = pattern;
	}

	public Object convert(Class aClass, Object o) {
		SimpleDateFormat format=new SimpleDateFormat(pattern);
		try {
			Date date=format.parse(o.toString());
			return date;
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}
}
